package cn.wolfcode.trip.app.web.controller;

import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.ViewPointQueryObject;
import cn.wolfcode.trip.base.service.IViewPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/viewPoints")
public class ViewPointController {
    private final IViewPointService viewPointService;

    @Autowired
    public ViewPointController(IViewPointService viewPointService) {
        this.viewPointService = viewPointService;
    }

    /*
        查询所有景点
        动作:GET
        资源:/viewPoints/{type}
        参数:
     */
    @GetMapping()
    public Object getViewPoints( @ModelAttribute("qo") ViewPointQueryObject qo) throws Exception {
        return viewPointService.queryViewPoints(qo);
    }

    /*
        查询某个景点
        动作:GET
        资源:/viewPoints/{id}
        参数:
     */
    @GetMapping("/{id}")
    public Object getViewPoint(@PathVariable Long id) {
        return viewPointService.get(id);
    }
}
